package cool.webstudy.admin.constant.enums.rescode.docker;

import cool.webstudy.admin.constant.enums.rescode.BaseResCodeEnum;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 莫振双
 * @date 2025/1/1 21:05
 * @description: 镜像相关错误码
 */
@Slf4j
public enum ImageResCodeEnum implements BaseResCodeEnum {
    RC_ERROR_NOT_EXIST("160001", "docker镜像：{0}缺失，请添加镜像后再试！")
    ;
    private String code;
    private String msg;

    ImageResCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }

    /**
     * 根据code获取msg静态方法，每个响应状态码枚举类都应有这个方法
     */
    public static ImageResCodeEnum getMsgByCode(String code) {
        for (ImageResCodeEnum containerResCodeEnum : ImageResCodeEnum.values()) {
            if (containerResCodeEnum.code().equals(code)) {
                return containerResCodeEnum;
            }
        }
        log.error("getMsgByCode error:无法获取枚举值");
        return null;
    }
}
